/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>Project: SpringBootPro - SwaggerConfig</p>
 * <p>Powered by yzc On 2023-11-13 14:24:16</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {

    @Bean
    public Docket createDocket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                //.enable(true) //为true可以访问 false不能访问
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.yzc.controller")) //扫描包，指明控制类
                .paths(PathSelectors.ant("/api_V1.0/**"))  //路劲匹配
                .build();
    }

    public ApiInfo getApiInfo(){
        return new ApiInfoBuilder()
                .title("XX管理系统")  //系统名称
                .description("Swagger接口文档，里面包括了所有请求以及参数信息")  //系统描述
                .contact(new Contact("誰说柚子不酸","http://localhost","1524059518@qq.com"))
                .version("v1.0")
                .build();
    }
}
